package com.ljh.account.service;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ljh.account.dao.Income;
import com.ljh.account.mapper.IncomeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;


import com.ljh.account.dao.Resp.IncomeResp;

import java.util.Map;

@Service
public class IncomeService {

    @Autowired
    private IncomeMapper incomeMapper;


    public PageInfo getIncomeWithFilter(Long userId, Integer categoryId, Integer bankAccountId, BigDecimal minAmount, BigDecimal maxAmount,int page,int size) {
        PageHelper.startPage(page, size);
        List<IncomeResp> list = incomeMapper.getIncomeWithFilter(userId, categoryId, bankAccountId, minAmount, maxAmount);
        return new PageInfo<>(list);
    }
    public IncomeResp getIncomeById(int id) {
        return incomeMapper.getIncomeById(id);
    }

    public void insertIncome(Income income) {
        incomeMapper.insertIncome(income);
    }

    public void updateIncome(Income income) {
        incomeMapper.updateIncome(income);
    }

    public void deleteIncome(Long id) {
        incomeMapper.deleteExpense(id);
    }
}
